package top.api.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

public enum CommonGoodsPayStatusEnum {
    // 支付状态(未出售: 0 已出售: 1 已退款: 2 临时锁单: 3)
    NOTSOLD(0,"未出售"),
    SOLD(1,"已出售"),
    REFUNDED(2,"已退款"),
    LOCK(3,"临时锁单");

    @EnumValue
    @JsonValue
    private final int code;

    private final String status;

    CommonGoodsPayStatusEnum(int code, String status) {
        this.code = code;
        this.status = status;
    }

    public int getCode() {
        return code;
    }

    public String getStatus() {
        return status;
    }

    public static CommonGoodsPayStatusEnum getCommonPayStatusEnumByCode(int code) {
        for (CommonGoodsPayStatusEnum commonGoodsPayStatusEnum : CommonGoodsPayStatusEnum.values()) {
            if (commonGoodsPayStatusEnum.getCode() == code) {
                return commonGoodsPayStatusEnum;
            }
        }
        throw new RuntimeException("没有满足条件的枚举");
    }
}
